﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Common;
using DemoManageSys.Areas.Filters;
using IBLL;
using Microsoft.AspNetCore.Mvc;
using Models;
using Models.DTO;

namespace DemoManageSys.Areas.API.Controllers
{
    [Area("API")]
    public class CategoryController : Controller
    {
        private ICategoryBLL _categoryBLL;

        public CategoryController(
            ICategoryBLL categoryBLL
            )
        {
            _categoryBLL = categoryBLL;
        }

        #region 获取商品类别表的方法 (GetCategoryes)
        /// <summary>
        /// 获取商品类别表的方法
        /// </summary>
        /// <param name="limit"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetCategory(int limit, int page, string categoryName)
        {
            int count;
            List<GetCategoryDTO> getCategoryDTOs = _categoryBLL.GetCategory(limit, page, categoryName, out count);
            ReturnResule resule = new ReturnResule()
            {
                Code = 0,
                Msg = "获取成功",
                Data = getCategoryDTOs,
                Count = count
            };
            return Json(resule);
        }
        #endregion
    }
}